package com.example.controller;

import com.example.pojo.Permissions;
import com.example.pojo.Result;
import com.example.service.impl.PermissionsServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
@CrossOrigin
@RestController
public class PermissionsController {
    @Autowired
    private PermissionsServiceImpl permissionsService;

    @Autowired
    private HttpServletRequest request;

    //实名验证
    @PostMapping("/realname")
    public Result realName(@RequestBody Permissions permissions){
        System.out.println(permissions);
        if(permissions.getRealName()==null || permissions.getRealName()==""){
            return Result.error("请输入名字");
        }
        if(permissions.getIdCard()==null || permissions.getIdCard()==""){
            return Result.error("请输入身份证");
        }
        /*if(permissions.getIdCardz()==null || permissions.getIdCardz()==""){
            return Result.error("请上传身份证正面");
        }
        if(permissions.getIdCardf()==null || permissions.getIdCardf()==""){
            return Result.error("请上传身份证反面");
        }*/

        permissionsService.realName(permissions,request);
        return Result.success();
    }

}
